package com.ruoyi.web.api;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ruoyi.base.domain.BaseMat;
import com.ruoyi.base.domain.BaseMatGroup;
import com.ruoyi.base.service.IBaseMatGroupService;
import com.ruoyi.base.service.IBaseMatService;
import com.ruoyi.common.core.domain.AjaxResult;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/dashBoard")
public class DashBoardController {

    @Autowired
    IBaseMatService baseMatService;

    @Autowired
    IBaseMatGroupService baseMatGroupService;
    public AjaxResult getStorageLevel(){
        List<BaseMat> list = baseMatService.list();
        list.forEach(item->{
            LambdaQueryWrapper<BaseMatGroup>  lqw = new LambdaQueryWrapper<>();
            lqw.eq(BaseMatGroup::getTargetId,item.getMatId());
            lqw.eq(BaseMatGroup::getTargetType,0);
            lqw.le(BaseMatGroup::getStatus,3);
            item.setCount(baseMatGroupService.count());
        });
        return AjaxResult.success(list);
    }

}
